package com.zhuiYun.project.api.order.mapper;

import com.zhuiYun.project.api.order.entity.Commorder;
import com.zhuiYun.project.api.order.model.CommorderModel;
import com.zhuiYun.project.common.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CommorderMapper extends BaseMapper<Commorder> {





    @Select("SELECT a.*,b.nick_name AS userB,c.commodity_name AS commodityNameB " +
            "FROM commodity_order a left JOin orders d on d.id = a.orders_id  LEFT JOIN commodity c ON a.commodity_id = c.id LEFT JOIN user b ON d.user_id = b.id where d.id=#{id}")

    @Results({
            @Result(property="commodityOrderNumber",column="commodity_order_number"),
            @Result(property="userId",column="user_id"),
            @Result(property="commodityId",column="commodity_id"),
            @Result(property="commodityPrice",column="commodity_price"),
            @Result(property="createTime",column="create_time"),
            @Result(property="updateTime",column="update_time"),
            @Result(property="ordersId",column="orders_id"),
            @Result(property="orderStatus",column="order_status"),
            @Result(property="commodityQuantity",column="commodity_quantity"),
    })
    List<CommorderModel> commorderlist(CommorderModel commorderModel);
}
